#include "GPSEncode.h"

void init_header(header *h, int type, int length)
{
	h->type = type;
	h->z1=0;
	h->id=0;
	h->length=length;
}

void encode_header(header *header)
{
	header->id = htons(header->id);
	header->length = htonl(header->length);
}

void encode_location(location *loc)
{
	loc->latitude = htonl(loc->latitude);
	loc->longitude = htonl(loc->longitude);
	loc->altitude = htonl(loc->altitude);
	loc->u_id = htonl(loc->u_id);
}

void decode_header(header *header)
{
	header->id = ntohs(header->id);
	header->length = ntohl(header->length);
}

void decode_location(location *loc)
{
	loc->latitude = ntohl(loc->latitude);
	loc->longitude = ntohl(loc->longitude);
	loc->altitude = ntohl(loc->altitude);
	loc->u_id = ntohl(loc->u_id);
}
